package _Pan3D.base
{
	import flash.geom.Point;
	import flash.geom.Vector3D;

	public class MakeModelData
	{
		public static function makeBoxTampData(hitbox:ObjectHitBox,scale:Number):ObjData
		{
			var objData:ObjData=new ObjData;
			
			var Vitem:Array=new Array();
            
			var w:Number=Math.max(Math.abs(hitbox.beginx),Math.abs(hitbox.endx))*scale
			var h:Number=Math.max(Math.abs(hitbox.beginz),Math.abs(hitbox.endz))*scale

			
			var bx:Number=-10;
			var by:Number=0;
			var bz:Number=-10;
			var ex:Number=10;
			var ey:Number=20;
			var ez:Number=10;
			
			bx=-w;
			ex=w;
			bz=-h;
			ez=h;
			by=hitbox.beginy*scale;
			ez=hitbox.endy*scale;
			
			
			

			//手工写入一个盒子的模型
			Vitem.push(new Vector3D(bx,by,ez));
			Vitem.push(new Vector3D(bx,by,bz));
			Vitem.push(new Vector3D(ex,by,bz));
			Vitem.push(new Vector3D(ex,by,ez));
			
			Vitem.push(new Vector3D(bx,ey,ez));
			Vitem.push(new Vector3D(bx,ey,bz));
			Vitem.push(new Vector3D(ex,ey,bz));
			Vitem.push(new Vector3D(ex,ey,ez));
			
			/*
			Vitem.push(new Vector3D(-10,0,10));
			Vitem.push(new Vector3D(-10,0,-10));
			Vitem.push(new Vector3D(10,0,-10));
			Vitem.push(new Vector3D(10,0,10));
			
			Vitem.push(new Vector3D(-10,20,10));
			Vitem.push(new Vector3D(-10,20,-10));
			Vitem.push(new Vector3D(10,20,-10));
			Vitem.push(new Vector3D(10,20,10));
			
			*/
			
			
			//不考虑是否是正面
			var Iitem:Array=new Array();
			Iitem.push(0,1,2);
			Iitem.push(0,2,3);
			
			Iitem.push(4,5,6);
			Iitem.push(0,6,7);
			
			Iitem.push(5,1,2);
			Iitem.push(5,2,6);
			
			Iitem.push(6,2,3);
			Iitem.push(6,3,7);

			Iitem.push(4,0,1);
			Iitem.push(4,1,5);
			
			Iitem.push(4,0,3);
			Iitem.push(4,3,7);

			objData.vertices=new Vector.<Number>;
			objData.indexs=new Vector.<uint>;
			for(var i:int=0;i<Iitem.length;i++)
			{
				var P:Vector3D=Vitem[Iitem[i]];
				objData.vertices.push(P.x,P.y,P.z);
				objData.indexs.push(i);
				
			}
			return objData;
            
		}

		
		
	}
}